package com.example.shop.controller;

import com.example.shop.controller.dto.UserDTO;
import com.example.shop.entity.User;
import com.example.shop.model.ApiResponse;
import com.example.shop.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * author: adnaan
 * create: 2023-11-07 13:48
 * Description:
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    @PostMapping("/login")
    public ApiResponse login(@RequestBody UserDTO userDTO){
        return userService.login(userDTO);
    }

    @PostMapping("/register")
    public ApiResponse register(@RequestBody User user){
        return userService.register(user);
    }

    @PostMapping("/loginOut")
    public ApiResponse loginOut(@RequestBody UserDTO userDTO){
        return userService.loginOut(userDTO);
    }

    @PutMapping("/updateUser")
    public ApiResponse updateUser(@RequestBody User user){
        return userService.updateUser(user);
    }
}
